package com.deryun.tyl.service.impl;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Service;

import com.deryun.tyl.bean.Standard;
import com.deryun.tyl.bean.User;
import com.deryun.tyl.dao.impl.StandardDaoImpl;

@Service("standardServiceImpl")
public class StandardServiceImpl {
	
	@Resource(name="standardDaoImpl")
	private StandardDaoImpl standardDaoImpl;
	
	public int addStandard(HttpServletRequest request,Standard standard){
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		standard.setPublishDate(df.format(new Date()));
		standard.setPublishMan(((User)request.getSession().getAttribute("user")).getContactMan());
		return standardDaoImpl.addStandard(standard);
	}
	
	public List<Standard> getAllStandard(){
		return standardDaoImpl.getAllStandard();
	}
	
	public List<Standard> getUserStandard(String publishUserId){
		return standardDaoImpl.getUserStandard(publishUserId);
	}
	
	public int deleteStandard(int id){
		return standardDaoImpl.deleteStandard(id);
	}
	
	public List<Standard> getNewStandard(){
		return standardDaoImpl.getNewStandard();
	}
	
	public int modifyStandard(Standard standard){
		return standardDaoImpl.modifyStandard(standard);
	}
	
	public Standard getStandardById(int id){
		return standardDaoImpl.getStandardById(id);
	}
	
	public int setResult(Standard standard){
		return standardDaoImpl.setResult(standard);
	}
}
